﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mesoBoard.Data.Repositories
{
    public class ReportedPostRepository : IReportedPostRepository
    {
        private mbEntities db;

        public ReportedPostRepository(mbEntities mbDataContext)
        {
            this.db = mbDataContext;
        }

        public IEnumerable<ReportedPost> GetReportedPosts()
        {
            return db.ReportedPosts.AsEnumerable();
        }

        public ReportedPost GetReportedPost(int ReportedPostID)
        {
            return db.ReportedPosts.FirstOrDefault(x => x.PostID == ReportedPostID);
        }

        public void DeleteReportedPost(int ReportedPostID)
        {
            db.ReportedPosts.DeleteObject(GetReportedPost(ReportedPostID));
            db.SaveChanges();
        }

        public void CreateReportedPost(ReportedPost TheReportedPost)
        {
            db.ReportedPosts.AddObject(TheReportedPost);
            db.SaveChanges();
        }

        public void SubmitChanges()
        {
            db.SaveChanges();
        }

    }
}
